<?php include_partial('aoiFrontPartials/contentHeader',
  array(
    'nav'=>array(
      array('url'=>url_for('admin_home'),'title'=>'Admin')
    ),
    'title'=>'Admin',
    'description'=>''
  )
); ?>

<section id="content">
  <div class="container">
    
    <div id="mainbody">
      
      <div class="row">
        <div class="span12">

          <h1><?php echo $leg->getName();?></h1>

        <?php include_partial('form', array('form' => $form)) ?>

          <h2>Passengers</h2>

          <form method="get" action="<?php echo url_for('admin_legs_edit',array('action'=>'edit')) ?>">
            <input type="hidden" name="id" value="<?php echo $leg->getId(); ?>"/>
            <fieldset>
          <select name="passenger_status">
            <option value="">All reservations</option>
            <option value="created"<?php if($passenger_status == 'created') echo ' selected'; ?>>New reservations</option>
            <option value="pending"<?php if($passenger_status == 'pending') echo ' selected'; ?>>Payment pending</option>
            <option value="validated"<?php if($passenger_status == 'validated') echo ' selected'; ?>>Payment validated</option>
            <option value="cancelled"<?php if($passenger_status == 'cancelled') echo ' selected'; ?>>Cancelled</option>
          </select>
            <button class="btn btn-success">search</button>
          </fieldset>
          </form>

          <table class="table table-striped">
            <thead>
              <tr>
                <th>Ticket code</th>
                <th>Firstname</th>
                <th>Lastname</th>
                <th>ID type</th>
                <th>ID ref</th>
                <th>gender</th>
                <th>age</th>
                <th>address</th>
                <th>city</th>
                <th>notes</th>
                <th>Reservation</th>
                <th>Reservation status</th>
              </tr>
            </thead>
            <tbody>
              <?php 

                  $reservation_status_labels = array(
                      'created'=>'New',
                      'pending'=>'Payment pending',
                      'validated'=>'Payment validated',
                      'cancelled'=>'Cancelled',
                  );
              ?>

              <?php foreach($passengers->getRawValue() as $passenger): ?>
              <tr>
                <td><?php echo $passenger['ticket_code']; ?></td>
                <td><?php echo $passenger['firstname']; ?></td>
                <td><?php echo $passenger['lastname']; ?></td>
                <td><?php echo $passenger['id_type']; ?></td>
                <td><?php echo $passenger['id_ref']; ?></td>
                <td><?php echo $passenger['civility']; ?></td>
                <td><?php echo $passenger['birthday']; ?></td>
                <td><?php echo $passenger['address']; ?></td>
                <td><?php echo $passenger['city']; ?></td>
                <td><?php echo $passenger['notes']; ?></td>
                <td>
                  <a href="<?php echo url_for('admin_reservations_edit',array('action'=>'edit','id'=>$passenger['reservation_id'])) ?>">
                      <?php echo $passenger['reservation_ref']; ?>
                  </a>
                </td>
                <td>
                <?php 
                  echo $reservation_status_labels[$passenger['reservation_status']] ;
                ?></td>
              </tr>
            <?php endforeach; ?>
            </tbody>
          </table>
              <p><a target="_blank" href="<?php echo url_for('admin_legs_edit', array('action'=>'export', 'id'=>$leg->getId())) ?>">Get full Excel table</a></p>
        </div> <!-- end span12 -->
      </div><!-- end row -->
    </div><!-- end mainbody -->
  </div><!-- end container -->
</section>

